//该文件专门用于创建整个应用的路由器

import VueRouter from "vue-router";
import LoginPage from "@/components/LoginPage.vue";
import HomeView from "@/components/view/HomeView.vue";
import PhotoView from "@/components/view/PhotoView.vue";
import DynamicView from "@/components/view/DynamicView.vue";
import LetterView from "@/components/view/LetterView.vue";
import SPage from "@/components/common/SPage.vue";


//创建并默认暴露一个路由器
const router = new VueRouter({
    routes: [
        {
            path: '/login',
            component: LoginPage,
            meta: {title: "登录"}
        },
        {
            path: '/index',
            component: SPage,
            children:[
                {
                    name: 'home',
                    path: 'home',
                    component:HomeView,
                    meta: {title: "首页"},
                },
                {
                    name: 'photo',
                    path: 'photo',
                    component:PhotoView,
                    meta: {title: "相册"}
                },
                {
                    name: 'dynamic',
                    path: 'dynamic',
                    component:DynamicView,
                    meta: {title: "动态"}
                },
                {
                    name: 'letter',
                    path: 'letter',
                    component:LetterView,
                    meta: {title: "私信"}
                }
            ]
        },
    ]
});


router.afterEach((to) => {
    document.title = "Strelitzia-"+to.meta.title
})

export default router
